package com.Comtroller;


import com.Servce.impl.StudentServiceimpl;
import com.domain.Student;
import org.junit.Test;

import java.sql.SQLException;
import java.util.List;

public class StudnetComtroller {
    StudentServiceimpl studentServiceimpl = new StudentServiceimpl();
    @Test
    public void findAll() throws SQLException {
        List<Student> all = studentServiceimpl.findAll();
        for (Student student : all) {
            System.out.println(student);
        }
    }
    @Test
    public void findById(){
        Student byId = studentServiceimpl.findById(2);
        System.out.println(byId);
    }
    @Test
    public void insert(){
        Student student = new Student(null,"tom",18,"1998-08-10");
        int insert = studentServiceimpl.insert(student);
        System.out.println(insert>0?"添加成功" :"添加失败");
    }
    @Test
    public void update(){
        Student student = new Student(1,"tom",17,"1998-08-10");
        int insert = studentServiceimpl.update(student);
        System.out.println(insert>0?"修改成功" :"修改失败");
    }
    @Test
    public void delete(){
        int insert = studentServiceimpl.delete(1);
        System.out.println(insert>0?"删除成功" :"删除失败");
    }
}
